package com.zdlyh.controller;

import com.zdlyh.domain.ResponseResult;
import com.zdlyh.domain.dto.TagListDto;
import com.zdlyh.service.TagService;
import com.zdlyh.domain.vo.PageVo;
import com.zdlyh.domain.vo.TagVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    @GetMapping("/list")
    public ResponseResult<PageVo> getTagList(Integer pageNum, Integer pageSize, TagListDto tagListDto){
        return tagService.getTagList(pageNum,pageSize,tagListDto);
    }

    @PostMapping
    public ResponseResult addTag(@RequestBody TagVo tagVo){
        return tagService.addTag(tagVo);
    }

    @GetMapping("/{id}")
    public ResponseResult getTagById(@PathVariable("id") Long id){
        return tagService.getTagById(id);
    }

    @PutMapping
    public ResponseResult updateTag(@RequestBody TagVo tagVo){
        return tagService.updateTag(tagVo);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteTagById(@PathVariable("id") Long id){
        return tagService.deleteTagById(id);
    }

    @GetMapping("/listAllTag")
    public ResponseResult getListAllTag(){
        return tagService.getListAllTag();
    }
}
